
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class DmsMachineMaintenanceRuleServiceImpl implements DmsMachineMaintenanceRuleService  {

    @Resource
    private DmsMachineMaintenanceRuleMapper dmsMachineMaintenanceRuleMapper;

    /**
     * 获取 DmsMachineMaintenanceRule 分页列表
     */
    @Transactional
    public IPage getDmsMachineMaintenanceRulePagination( PaginationVo paginationVo, DmsMachineMaintenanceRuleQuery dmsMachineMaintenanceRuleQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<DmsMachineMaintenanceRuleEntity> lqs = new LambdaQueryWrapper();
        dmsMachineMaintenanceRuleMapper.selectPage(page, lqs);

        List<DmsMachineMaintenanceRuleEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 DmsMachineMaintenanceRule 所有数据
     *
    */
    @Transactional
    public List<DmsMachineMaintenanceRuleEntity> getDmsMachineMaintenanceRuleAllList( DmsMachineMaintenanceRuleQuery dmsMachineMaintenanceRuleQuery ) throws Exception {

        LambdaQueryWrapper<DmsMachineMaintenanceRuleEntity> lqs = new LambdaQueryWrapper();
        List<DmsMachineMaintenanceRuleEntity> list = dmsMachineMaintenanceRuleMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 DmsMachineMaintenanceRule 详情
    */
    @Transactional
    public DmsMachineMaintenanceRuleEntity getDmsMachineMaintenanceRuleDetail( Long id) throws Exception {

        DmsMachineMaintenanceRuleEntity dmsMachineMaintenanceRule = dmsMachineMaintenanceRuleMapper.selectById(id);
        return dmsMachineMaintenanceRule;
    }


    /**
     * 新增 DmsMachineMaintenanceRule
     * */
    @Transactional
    public void addDmsMachineMaintenanceRule(DmsMachineMaintenanceRuleVo dmsMachineMaintenanceRuleVo) throws Exception {

        DmsMachineMaintenanceRuleEntity dmsMachineMaintenanceRule = new DmsMachineMaintenanceRuleEntity();
        ReflectionCopy.copyProperties( dmsMachineMaintenanceRule, dmsMachineMaintenanceRuleVo );
        dmsMachineMaintenanceRuleMapper.insert(dmsMachineMaintenanceRule);
        return;
    }


    /**
     * 更新 DmsMachineMaintenanceRule
     * */
    @Transactional
    public void updateDmsMachineMaintenanceRule( DmsMachineMaintenanceRuleVo dmsMachineMaintenanceRuleVo) throws Exception {

        if( dmsMachineMaintenanceRuleVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        DmsMachineMaintenanceRuleEntity dmsMachineMaintenanceRule = new DmsMachineMaintenanceRuleEntity();
        ReflectionCopy.copyProperties( dmsMachineMaintenanceRule, dmsMachineMaintenanceRuleVo );
        dmsMachineMaintenanceRuleMapper.updateById(dmsMachineMaintenanceRule);
        return;
    }

    /**
     * 删除 DmsMachineMaintenanceRule
     * */
    @Transactional
    public void batchRemoveDmsMachineMaintenanceRule( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        dmsMachineMaintenanceRuleMapper.deleteBatchIds(ids);
    }

}

      